import SwiftUI

struct TransactionCard: View {
    let expense: Expense

    var body: some View {
        HStack(spacing: 16) {
            Circle()
                .fill(Color.blue.opacity(0.15))
                .frame(width: 48, height: 48)
                .overlay(
                    Image(systemName: iconForCategory(expense.category))
                        .font(.title3)
                        .foregroundColor(.blue)
                )


            VStack(alignment: .leading, spacing: 4) {
                Text(expense.establishment)
                    .font(.headline)

                Text(expense.category)
                    .font(.subheadline)
                    .foregroundColor(.secondary)
            }

            Spacer()

            Text("$\(expense.amount, specifier: "%.2f")")
                .font(.headline)
        }
        .padding(16)
        .background(
            RoundedRectangle(cornerRadius: 20)
                .fill(Color(.systemBackground))
                .shadow(color: Color.black.opacity(0.05), radius: 5, y: 3)
        )
    }

    private func iconForCategory(_ cat: String) -> String {
        switch cat {
        case "Food": return "fork.knife"
        case "Transport": return "car.fill"
        case "Shopping": return "bag.fill"
        case "Bills": return "doc.text.fill"
        case "Travel": return "airplane"
        default: return "creditcard"
        }
    }
}


struct MonthlySummaryCard: View {
    var spentThisMonth: Double = 0

    var body: some View {
        VStack(alignment: .leading, spacing: 10) {
            Text("This Month")
                .font(.headline)

            Text("$\(spentThisMonth, specifier: "%.2f") spent")
                .font(.largeTitle.bold())

            ProgressView(value: spentThisMonth > 0 ? 0.01 : 0)
        }
        .padding()
        .background(Color.blue.opacity(0.15))
        .cornerRadius(14)
        .padding()
    }
}
